<?php

$link =  mysqli_connect("localhost","root","root","2113");
$sql="SELECT * FROM messages";
$res =  mysqli_query($link,$sql);
// 执行结果集获取数据
$arr = [];
while($one=mysqli_fetch_assoc($res)){
	$arr[] = $one;
}

$str =  json_encode($arr);
echo $str;



?>